# 作用：自动把类传进去
from file_data import settings


class Mysql:
    def __init__(self, ip, port):
        self.ip = ip
        self.port = port

    def f1(self):
        print(self.ip, self.port)

    @classmethod  # 自动传入类
    def instance_from_conf(cls):
        # 接收模块的参数
        obj = cls(settings.ip, settings.port)
        print(obj.__dict__)


# 调用类方法格式：类名.被修饰的方法名()
obj = Mysql.instance_from_conf()
obj